$(document)
		.ready(
				function() {
					// 供应商下拉框的数据绑定
					var purchaseOrderVue = new Vue({
						el : '#purchaseOrderDiv',
						data : {
							items : null
						},
						methods : {
							sendConfirm : function(purchaseOrder) {
								openShowPurchaserOrderBox(purchaseOrder);
							}
						},
						beforeCreate : function() {
							updatePurchaseOrderList();
						}
					});

					var purchaseOrderBox=null;
					// 打开查看采购申请窗口
					function openShowPurchaserOrderBox(purchaseOrder) {
						var url = 'purchaseOrder/getPurchaseOrderByPrimaryKeyReturnTo?purchaseOrderId='
								+ purchaseOrder.purchaseOrderId
								+ '&remark='
								+ 'show' + '&returnTo=showPurchaseOrder';
						purchaseOrderBox=layer.open({
							type : 2,
							maxmin : true,
							title : '查看采购申请',
							offset : '4%',
							btnAlign : 'c',
							area : [ '70%', '92%' ],
							btn : [ '确认发货', '拒绝发货' ],
							shadeClose : true, // 点击遮罩关闭
							yes : function() {
								var data={
									"purchaseOrderId":	purchaseOrder.purchaseOrderId,
									"state":4
								};
								
								sendConfirmAlert('确认发货？','purchaseOrder/sendMaterialAjax',data);
							},
							btn2 : function() {
								var data={
										"purchaseOrderId":	purchaseOrder.purchaseOrderId,
										"state":5
									};
									
									sendConfirmAlert('拒绝发货？','purchaseOrder/sendMaterialAjax',data);
							},
							content : SERVER_PRE_URL + url
						});
						
						
						
						
				

					}
					
					function sendConfirmAlert(title,url,data){
						layer.confirm(title, {
							  btn: ['确定','取消'] //按钮
							}, function(){
								baseUtil.httpSend(url, data, showConfirmResult);
							}, function(){
								
							});
					}
					
					function showConfirmResult(result){
						if (result == 1) {
							layer.msg('操作成功!');
							layer.close(purchaseOrderBox);
							updatePurchaseOrderList();
						} else {
							layer.msg('操作失败!');
						}
					}

					//更新采购订单的列表
					function updatePurchaseOrderList() {
						$.get(SERVER_PRE_URL
								+ "purchaseOrder/getPurchaseOrderListByStateAndSupplierIdAjax?state=2",
								function(data) {
									purchaseOrderVue.items = data;
								});
					}

				});